package wusiyuan.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import entity.User_Address;
import entity.User_Inf;
import wusiyuan.service.GetTheAddressService;
import wusiyuan.service.SetThedefaultAddressService;
import wusiyuan.service.impl.GetTheAddressServiceImpl;
import wusiyuan.service.impl.SetThedefaultAddressServiceImpl;

/**
 * Servlet implementation class SetThedefaultAddressServlet
 */
public class SetThedefaultAddressServlet extends HttpServlet {
	private UserDao ud = new UserDaoImpl();
	private GetTheAddressService gta = new GetTheAddressServiceImpl();
	private SetThedefaultAddressService sta = new SetThedefaultAddressServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String userName = "章敏";
		User_Inf ui = ud.queryUserByUsername(userName);
		response.setCharacterEncoding("utf-8");
		String consignee = request.getParameter("consignee");
		String phone = request.getParameter("phone");
		User_Address ua = gta.selectAddressByconsigneeAndPhone(consignee, phone);
		Integer i = sta.SetThedefaultAddress(ui.getUserId(), ua.getUser_addr_id());
		Integer j = sta.SetTheOtherAddress(ui.getUserId(), ua.getUser_addr_id());
		System.out.println(i);
		System.out.println(j);

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
